<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";
%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <base href="<%=basePath%>">
    
    <title>My JSP 'json.jsp' starting page</title>
    
	<meta http-equiv="pragma" content="no-cache">
	<meta http-equiv="cache-control" content="no-cache">
	<meta http-equiv="expires" content="0">    
	<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
	<meta http-equiv="description" content="This is my page">
	<!--
	<link rel="stylesheet" type="text/css" href="styles.css">
	-->
	<script type="text/javascript">
	//定义一个对象
	var o={"name":"电视","price":"5500"}; 
	document.write(o.name+"---"+o.price+"<br/>");
	var objs = [ {"name":"电视","price":"5500"},
	                  {"name":"洗衣机","price":"1500"},
	                  {"name":"笔记本电脑","price":"9500"}];
	document.write( objs[2].name +"<br>");
	for(var i=0;i <objs.length; i++){
		document.write(objs[i].name +"-->"+objs[i].price+"<br/>");
	}
	var s={"name":"李洁洁","性别":"男","sleep":function(){ alert("睡觉ing"); }};
	//s.sleep();
	//eval把普通的json字符串转换成json对象
	var t = "{'name':'张三','sex':'男'}";
	var ot=eval( "(" + t + ")" );
	alert(ot.name);
	
	</script>

  </head>
  
  <body>
 
  </body>
</html>
